package com.qfedu.stussm.controller;

import com.qfedu.stussm.entity.Course1;
import com.qfedu.stussm.entity.Course2;
import com.qfedu.stussm.service.intf.Course1Service;
import com.qfedu.stussm.service.intf.Course2Service;
import com.qfedu.stussm.vo.PageBeanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/api/cou2/")
public class Course2Controller {
    @Autowired
    private Course2Service service;
    @PostMapping("save.do")
    public String save(Course2 course2){

        service.add(course2);
        return "redirect:/course2list.html";
    }
    @GetMapping("page.do")
    @ResponseBody
    public PageBeanVo page(int page, int limit ,String c2_name){
        return service.selectAll(page, limit , c2_name);
    }
    @PostMapping("update.do")
    public String update(Course2 course2){
        int update = service.update(course2);
        return "course2list.html";
    }
    @PostMapping("del.do")
    public String del(int c2_id){
        int del = service.del(c2_id);
        return "course2list.html";
    }

}
